package com.f6.weixin.houtai.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.f6.exceptions.BusinessException;
import com.f6.service.CommonService;
import com.f6.utils.SystemConstans;
import com.f6.vo.DBParameter;
import com.f6.weixin.vo.Dish;

@Controller
@RequestMapping(SystemConstans.HOUTAI + "/order")
public class OrderController {
	private Logger logger = LoggerFactory.getLogger(OrderController.class);
	@Autowired
	private CommonService commonservice;

	@RequestMapping(value = "list", method = RequestMethod.GET)
	public ModelAndView orderpreview() throws IOException, BusinessException {
		logger.info("enter order list");
		ModelAndView mv = new ModelAndView();
		mv.setViewName("ht/orderlist");

		Map paramap = new HashMap<String, String>();
		DBParameter dbparam = new DBParameter();
		dbparam.setAction("getAllOrders");
		dbparam.setModule("putong.Order");
		dbparam.setParameter(paramap);

		List<Map<String, ?>> list = commonservice.queryMore(dbparam);
		// List<Dish> list = new ArrayList<Dish>();
		logger.info("获取列表:" + list.size());
		mv.addObject("orderlist", list);
		return mv;
	}

	@RequestMapping(value = "orderconfirm", method = RequestMethod.POST, produces = "application/text;charset=UTF-8")
	public ModelAndView orderconfirm(HttpServletRequest request, @PathVariable String dishid, @RequestParam String access_token) throws IOException {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("dishdetai");
		Dish dish = null;
		mv.addObject("dishlist", dish);
		return mv;
	}
 

}
